package com.berchen.common.result;

import lombok.Data;

@Data
public class Result {

    private String msg;
    private Integer code;
    private Object data;

    private Result() {
    }

    public static Result ok() {

        return Result.set(ResultEnum.SUCCESS);
    }
    public static Result ok(Object data){
        Result ok = ok();
        ok.setData(data);
        return ok;
    }

    public static Result error(){
        return Result.set(ResultEnum.ERROR);
    }
    public static Result error(Object data){
        Result error = error();
        error.setData(data);
        return error;
    }

    public static Result set(ResultEnum resultEnum) {

        Result result = new Result();
        result.setMsg(resultEnum.getMsg());
        result.setCode(resultEnum.getCode());
        return result;
    }
}
